﻿using System;
using System.Collections.Generic;
using System.Text;

namespace T.FAS.Runtime.Base.Entity
{
    /// <summary>
    /// 变更数据
    /// </summary>
    [Serializable]
    public class TChangeData:TRecord
    {
        /// <summary>
        /// 数据变更类型
        /// </summary>
        public ChangeDataType ChangeDataType { get; set; }
        /// <summary>
        /// 变更列编号
        /// </summary>
        public string ColumnCode { get; set; }
        /// <summary>
        /// 变更列名称
        /// </summary>
        public string ColumnName { get; set; }
        /// <summary>
        /// 旧值
        /// </summary>
        public object OldValue { get; set; }
        /// <summary>
        /// 新值
        /// </summary>
        public object NewValue { get; set; }
        /// <summary>
        /// 顺序号
        /// </summary>
        public int SortOrder { get; set; }
        public TChangeLog this[int index]
        {
            get
            {
                if (List != null && List.Count > 0 && List.Count > index)
                    return List[index];
                return null;
            }
        }
        /// <summary>
        /// 子集变更数据
        /// </summary>
        public List<TChangeLog> List { get; set; }
        public TChangeLog _record;
        /// <summary>
        /// 关联变更数据
        /// </summary>
        public TChangeLog Record
        {
            get { return _record; }
            set
            {
                _record = value;
                base.CopyTRecord(_record);
            }
        }
    }
    /// <summary>
    /// 变更数据类型
    /// </summary>
    public enum ChangeDataType
    {
        /// <summary>
        /// 常规字段值变更
        /// </summary>
        Normal,
        /// <summary>
        /// Record节点数据变更
        /// </summary>
        Record,
        /// <summary>
        /// List节点数据变更
        /// </summary>
        List
    }
}
